Allow overlapping basic blocks#3662
Draft
Schaeff wants to merge 17 commits into
Draft
Conversation
leonardoalt
reviewed
Mar 13, 2026
| ) -> Option<u64> { | ||
| match instruction.opcode.as_usize() { | ||
| opcode::OPCODE_JAL => Some(pc + instruction.c.as_canonical_u32() as u64), | ||
| opcode::OPCODE_JALR => None, |
Member
There was a problem hiding this comment.
can be removed to fallback to _ because it's dynamic
Member
There was a problem hiding this comment.
Or actually:
We could potentially support this: JALR uses a register as input for the high bits of the destination, which is often set by AUIPC just before JALR.
Example (something like this):
auipc ra, <some_imm_hi> # sets ra = pc + some_imm_hi << 12 (something like this)
jalr ra, <some_imm_lo> # sets pc = ra + some_imm_lo
So we need to find the value of ra here. If jalr x0, imm, easy.
If jalr ra, imm, we can look at the previous instruction to check if it's AUIPC and read what was written to ra.
Collaborator
Author
There was a problem hiding this comment.
ah right i remember this
Collaborator
Author
There was a problem hiding this comment.
Implemented AUIPC + JALR
Schaeff
commented
Mar 13, 2026
|
|
||
| fn is_branching(instr: &Self::Instruction) -> bool; | ||
|
|
||
| /// Returns the static jump target of after a series of instructions, if known. |
Schaeff
commented
Mar 13, 2026
Comment on lines
+51
to
+69
| fn signed_field_to_i64<F: PrimeField32>(value: F) -> i64 { | ||
| let value = value.as_canonical_u32(); | ||
| if value < F::ORDER_U32 / 2 { | ||
| value as i64 | ||
| } else { | ||
| value as i64 - F::ORDER_U32 as i64 | ||
| } | ||
| } | ||
|
|
||
| fn jalr_imm<F: PrimeField32>(instruction: &Instruction<F>) -> u32 { | ||
| let imm_low = instruction.c.as_canonical_u32() & 0xffff; | ||
| let imm_high = if instruction.g == F::ONE { | ||
| 0xffff0000 | ||
| } else { | ||
| 0 | ||
| }; | ||
| imm_low | imm_high | ||
| } | ||
|
|
Collaborator
Author
There was a problem hiding this comment.
Not sure about these..
Collaborator
Author
|
closing in favor or #3669 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.